package com.qkjia.day03;

import java.util.concurrent.CountDownLatch;

public class Test04_CountDownLatch {
    public static void main(String[] args) throws InterruptedException {
        CountDownLatch countDownLatch = new CountDownLatch(6);
        for (int i = 0; i <5 ; i++) {
            new Thread(()->{
                System.out.println(Thread.currentThread().getName()+"\t号同学离开教室");
                //让计数器减1
                countDownLatch.countDown();
            },""+i).start();
        }
        countDownLatch.await();
        System.out.println(Thread.currentThread().getName()+"\t班长离开教室");
    }
}
